package com.mszlu.blog.controller;

import com.mszlu.blog.common.Result;
import com.mszlu.blog.entity.Category;
import com.mszlu.blog.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/detail")
    public Result details(){

        List<Category> list = categoryService.list();

        return Result.success(list);
    }

    @GetMapping("/detail/{id}")
    public Result detail(@PathVariable long id) {

        return categoryService.detail(id);
    }

    @GetMapping
    public Result categorys() {

        List<Category> list = categoryService.list();

        return Result.success(list);
    }

}
